import requests
from nose_parameterized import parameterized

import config
from api.ihrm_aip import Ihrmaip
from api.ihrm_manage_api import TestManage
from common.db_util import DBUtil
from common.ihrm_ass import IhrmAssert
from common.read_ihrm import ReadIhrm
from common.token_ihrm import TokenIhrm


class TestIhrm2:
    def setup_class(self):
        self.token = TokenIhrm.token_login()

    def setup(self):
        del_sql = f"delete from bs_user where mobile = '{config.TEL}';"
        DBUtil.uid_db(del_sql)

    def teardown(self):
        del_sql = f"delete from bs_user where mobile = '{config.TEL}';"
        DBUtil.uid_db(del_sql)

    ihrm_yy_file_pata = config.BASE_DIR + "/data/data_add.json"

    @parameterized.expand(ReadIhrm.ysy_json_data(ihrm_yy_file_pata))
    def test_login(self, body, status_code, success, code, message):
        login_resp = TestManage.add_emp_api(self.token, body)
        IhrmAssert.login_assert(login_resp, status_code, success, code, message)

